package day_2022_4_to_7.day48;

/**
 * 井字棋
 * @author haomin
 * @date 2022/04/28 08:30
 **/
public class Day10_1_checkWon {
    public boolean checkWon(int[][] board) {
        // 判断斜方向
        if(board[0][0] + board[1][1] + board[2][2] == 3) {
            return true;
        }
        if(board[2][0] + board[1][1] + board[0][2] == 3) {
            return true;
        }
        // 判断行列
        for (int i = 0; i < 3; i++) {
            if(board[i][0] + board[i][1] + board[i][2] == 3){
                return true;
            }
            if(board[0][i] + board[1][i] + board[2][i] == 3){
                return true;
            }
        }
        return false;
    }
}